<?php
include_once("../configure/admin.config.inc.php");	//--> admin global var
include_once("db.inc.php");							//--> db global var
include_once("Smarty.class.php");					//--> out template
include_once("Operation.php");						//--> Operation
include_once("Message.php");						//--> Message
require_once("controlHeader.php");					//--> system control header
include_once("Strings.php");						//--> String
include_once("Users.php");							//--> user

$objOperate	= new Operation($objSession->getLanguage());		//--> Operation
$objMessage	= new Message($uid);								//--> Message
$objString  = new Strings();									//--> String
$objUser 	= new Users($uid);								//--> user

$error_message = '';

$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
if(count($arrOperate) > 0){
	$strQuery = $_SERVER["REQUEST_URI"];
	$arrUrlInfo 	= pathinfo($strQuery);
	$selfFileName	= $arrUrlInfo['filename'];
	
	$arrOperateAllInfo = $objOperate->listFromCustom($arrOperate, " WHERE id in (".implode(",", $arrOperate).")");
	
	$i = 0; 
	foreach($arrOperateAllInfo as $key => $value){
		$strFileName = $selfFileName."_".$value['name'].".php";

		if(file_exists($strFileName)){
			$arrOperateInfo[$i]['name'] 		= $value['name'];
			$arrOperateInfo[$i]['viewName'] 	= $value['viewName'];
			
			$i++;
		}
	}
}

$arrDataList = $objMessage->lists($arrOperate, " ORDER BY id DESC", $page, DISPLAY_DATA_SIZE, '');
if(is_array($arrDataList)){
	foreach($arrDataList as $key => $value){
		if($value['userid'] > 0){
			$arrUserInfo = $objUser->getFromID($arrOperate, $value['userid']);
			$arrDataList[$key]['name'] = $arrUserInfo['name'];
		}
			
		$arrDataList[$key]['content'] = $objString->cut(strip_tags($value['content']), 60);
	}
}


/*----- out html -----*/
$smarty = new Smarty();		//----- out template
$smarty->template_dir = TEMPLATE_SYS_DIR;
$smarty->compile_dir  = CACHE_SYS_DIR;

$smarty->assign('error_message', $error_message);
$smarty->assign('menuGid', $menuGid);
$smarty->assign('menuid', $menuid);

$smarty->assign('selfFileName', $selfFileName);
$smarty->assign('arrOperateInfo', $arrOperateInfo);

$smarty->assign('arrList', $arrDataList);
$smarty->assign('PAGE_BAR', $objMessage->pagenav);

$smarty->display('listMessage.htm');
?>
